<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<title>订单评审管理</title>

	<!-- bootstrap -->
	<link href="__CSS__/bootstrap/bootstrap.css" rel="stylesheet" />

	<!-- libraries -->
	<!-- <link href="css/libs/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /> -->
	<link href="__CSS__/libs/font-awesome.css" type="text/css" rel="stylesheet" />

	<!-- global styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/layout.css">
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/elements.css">

	<!-- this page specific styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/libs/bootstrap-wizard.css">
	<link rel="stylesheet" href="__CSS__/libs/select2.css" type="text/css" />

	<link rel="stylesheet" href="__CSS__/new.css"/>
	<link rel="stylesheet" href="__CSS__/table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table-fixed-columns.css"/>
	<link rel="stylesheet" href="__CSS__/other.css"/>

	<!-- Favicon -->
	<!--<link type="image/x-icon" href="favicon.png" rel="shortcut icon"/>-->

	<!-- google font libraries -->
	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>

	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'UA-49262924-1', 'phoonio.com');
	  ga('send', 'pageview');

	</script>
	<style>
		.main-box{
			min-height: 820px;
		}
		@media (max-width:1320px){
			.main-box{
				min-height: 700px;
			}
		}

		.fixed-table-body-columns{
			height: 486px!important;
			top: 47px!important;
		}
		.calCancel{
			float: right;
		}

		.wizard-modal.modal{
			width:680px!important;
			/*height: 360px!important;*/
			margin-left: -336px!important;
		}
		#msg{
			background: rgba(255,255,255,0.6);
			border:1px solid #faf2cc;
			text-align:center;
			width: 150px;
			height: 30px;
			margin-left: 36%;
			border-radius: 3px;
		}
		/*固定前两列宽度设置*/
		.addWidth{
			width: 86px;
		}
	</style>
</head>
<body>
	<!--head-->
	{include file="pub/head"/}

	<div class="container" role="main">
		<div class="row">

				<!--left-->
				{include file="pub/left"/}

			<div class="col-md-10" id="content-wrapper">
				<!--<h2 class="pull-left">Last orders</h2>-->
				<div class="row">
					<div class="col-lg-12">
						<!--<div class="row">
							<div class="col-lg-12">-->
								<div class="main-box">
									<!--提示框-->
									<div id="msg">
										<img src="__IMG__/success.png" id="img" alt="" style="float: left;height: 29px;width: 36px;">
										<span id="sp" style="font-size: 14px;line-height: 30px;">提示信息</span>
									</div>
									<div class="clear-fix">
										{if condition="in_array('Order/save',$ownways)"}
										<button id="open-wizard" class="btn btn-primary">
											<i class="fa fa-plus-circle fa-lg"></i> 添加订单评审
										</button>
										{/if}
									</div>
									<!--搜索页-->
									<div class="col-sm-12 col-md-12 col-lg-12 col-xs-12" style="margin-top: 16px;">
										{include file="ord/search"/}
									</div>
									<div class="table-responsive clearfix">
										<table id="fixedTable" class="table table-striped jambo_table table-hover" data-toggle="table">
											<thead>
												<tr>
													<th class="text-center"><span>订单评审号</span></th>
													<th class="text-center"><span>上级-订单评审号</span></th>
													<th><span>国家 客户</span></th>

													<th><span>配件</span></th>
													<th><span>配件数量</span></th>

													<!--<th><span>客户联系方式</span></th>-->
													<th><span>下单联系人</span></th>
													<!--<th><span>下单联系人电话</span></th>-->
													<!--<th><span>国内货运</span></th>-->

													<th><span>基表型号</span></th>
													<th><span>表数量</span></th>
													<th><span>方案</span></th>

													<!--<th><span>内置止回阀</span></th>
													<th><span>内置滤网</span></th>
													<th><span>铭牌信息</span></th>
													<th><span>带唛头</span></th>-->

													<!--<th><span>固定/动态信道</span></th>-->
													<!--<th><span>红外开关</span></th>-->
													<!--<th><span>计量模式</span></th>
													<th><span>报警量</span></th>
													<th><span>透支量</span></th>
													<th><span>时区</span></th>-->

													<th><span>加密方式</span></th>
													<th><span>软件版本</span></th>
													<th><span>数据库</span></th>
													<th><span>USBkey</span></th>
													<th><span>生产状态</span></th>
													<th><span>生产负责人</span></th>
													<th><span>备注</span></th>
													<th class="text-center"><span>操作</span></th>
												</tr>
											</thead>
											<tbody>
												{volist name="orders" id="v"}
												{if condition="$v['parent_id'] eq '0'"}
												<tr>
													<td class="addWidth">{$v.oid}</td>
													<td>主表订单</td>
													<td>{$v.state} {$v.client}</td>

													<!--配件-->
													<td>/</td>
													<td>/</td>

													<td>{$v.order_placer}</td>

													<!--基表-->
													<td>{$v.meter_type}</td>
													<td>{$v.order_qty}</td>
													<td>{$v.pro_name}</td>


													<td>{$v.crypt}</td>
													<td>{$v.soft_version}</td>
													<td>{$v.sql_db}</td>
													<td>{$v.usbkey}</td>
													<td>{$v.status}</td>
													<td>/</td>
													<td>{$v.other}</td>
													<td>
														{if condition="in_array('Order/view',$ownways)"}
														<a href="{:url('Order/view',['oid'=>$v['oid']])}" class="table-link" title="查看详情">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-search-plus fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
														{if condition="in_array('Order/esavepa',$ownways)"}
														<a class="table-link" href="#" onclick=editpa("{$v['oid']}") title="修改信息">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
														{if condition="in_array('Order/epasta',$ownways)"}
														<a class="table-link" href="#" onclick=estatus("{$v['oid']}") title="修改状态">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil-square fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
														{if condition="in_array('Order/del',$ownways)"}
														<a class="table-link danger class-del" href="#" onclick=del("{$v['oid']}") title="删除">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-trash-o fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
													</td>
												</tr>
												{elseif condition="$status neq 3"/}
												<tr>
													<td class="addWidth">{$v.oid}</td>
													<td>{$v.parent_id}</td>
													<td>{$v.state} {$v.client}</td>

													<!--配件-->
													<td>{$v.fitting}</td>
													<td>{$v.fid_num}</td>

													<td>{$v.order_placer}</td>
													<!--基表-->
													<td>{$v.meter_type}</td>
													<td>{$v.order_qty}</td>
													<td>{$v.pro_name}</td>


													<td>{$v.crypt}</td>
													<td>{$v.soft_version}</td>
													<td>{$v.sql_db}</td>
													<td>{$v.usbkey}</td>
													<td>{$v.status}</td>
													<td>{$v.principle}</td>
													<td>{$v.other}</td>
													<td>

														<!--子订单-->
														{if condition="in_array('Order/esave',$ownways)"}
														<a class="table-link" href="#" onclick=edit("{$v['oid']}") title="修改状态">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil-square fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}

													</td>
												</tr>
												{elseif condition="($status eq 3) && ($v['principle'] eq $surname)"/}
												<tr>
													<td class="addWidth">{$v.oid}</td>
													<td>{$v.parent_id}</td>
													<td>{$v.state} {$v.client}</td>

													<!--配件-->
													<td>{$v.fitting}</td>
													<td>{$v.fid_num}</td>

													<td>{$v.order_placer}</td>
													<!--基表-->
													<td>{$v.meter_type}</td>
													<td>{$v.order_qty}</td>
													<td>{$v.pro_name}</td>


													<td>{$v.crypt}</td>
													<td>{$v.soft_version}</td>
													<td>{$v.sql_db}</td>
													<td>{$v.usbkey}</td>
													<td>{$v.status}</td>
													<td>{$v.principle}</td>
													<td>{$v.other}</td>
													<td>
														<!--子订单-->
														{if condition="in_array('Order/esave',$ownways)"}
														<a class="table-link" href="#" onclick=edit("{$v['oid']}") title="修改状态">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil-square fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}

													</td>
												</tr>
												{/if}
												{/volist}

											</tbody>
										</table>
										<!--分页-->
										<div style="text-align: center;">
											{$page}
										</div>
									</div>

									<!--添加弹出框-->
									{include file="ord/add"/}
                                    <!--修改弹出框-->
									<!--修改状态-->
									{include file="ord/estatus"/}
									{include file="ord/edit"/}
									<!--修改信息-->
									{include file="ord/editpa"/}
                                    <!--删除弹出框-->
                                    {include file="ord/del"/}

								</div>
							</div>
						</div>
						
					<!--</div>
				</div>-->
			</div>
		</div>
	</div>
	<!--foot-->
	{include file="pub/foot"/}

	<!-- global scripts -->
	<script src="__JS__/jquery.js"></script>

	<script src="__JS__/bootstrap.min.js"></script>

	<!-- this page specific scripts -->
	<script src="__JS__/bootstrap-wizard.js"></script>
	<script src="__JS__/select2.min.js"></script>

	<!-- theme scripts -->
	<script src="__JS__/scripts.js"></script>
	<script src="__JS__/bootstrap-table.js"></script>
	<script src="__JS__/bootstrap-table-fixed-columns.js"></script>
	<script>
        $('#fixedTable').bootstrapTable('destroy').bootstrapTable({
            fixedColumns: true,//固定列
            fixedNumber:2 //固定前两列
        })


		$('#sel2').select2();

		$.fn.wizard.logging = false;

		var wizard = $("#wizard-demo").wizard({
			showCancel: true
		});
        var foredit = $("#wizard-edit").wizard({
            showCancel: true
        });
        var foreditpa = $("#wizard-pa").wizard({
            showCancel: true
        });
        var foreditstatus = $("#wizard-est").wizard({
            showCancel: true
        });

		wizard.el.find(".wizard-ns-select").change(function() {
			wizard.el.find(".wizard-ns-detail").show();
		});

		wizard.el.find(".create-server-service-list").change(function() {
			var noOption = $(this).find("option:selected").length == 0;
			wizard.getCard(this).toggleAlert(null, noOption);
		});

		wizard.cards["name"].on("validated", function(card) {
			var hostname = card.el.find("#new-server-fqdn").val();
		});

		wizard.on("submit", function(wizard) {
			/*var submit = {
				"hostname": $("#new-server-fqdn").val()
			};*/

			setTimeout(function() {
				wizard.trigger("success");
				wizard.hideButtons();
				wizard._submitting = false;
				wizard.showSubmitCard("success");
				wizard.updateProgressBar(0);
			}, 2000);
			add();
			wizard.reset().close();
			//刷新页面
			window.location.reload();
		});
		$(".wizard-group-list").click(function() {
			alert("Disabled for demo.");
		});

		$("#open-wizard").click(function() {
			wizard.show();
			/*$('.wizard-cancel').text('取消');
			$('.wizard-back').text('上一步')
			$('.wizard-next').text('下一步');
			$('.btn-success').text('确定')*/
		});

		//wizard.show();

        $("#msg").addClass('forhid')

        function add() {
            /*基本信息*/
            var client = $("select[name='client_add']").val();
            var client_contacts = $("input[name='client_contacts_add']").val();
            var order_placer = $("input[name='order_placer_add']").val();
            var placer_phone = $("input[name='placer_phone_add']").val();
            var transport = $("textarea[name='transport_add']").val();
			/*表计参数*/
            var meter_id = $("select[name='meter_id_add']").val();
            // var meter_num = $("input[name='meter_num_add']").val();
            var order_qty = $("input[name='order_qty_add']").val();
            // var model_id = $("select[name='model_id_add']").val();
            var pro_id = $("select[name='pro_id_add']").val();
			/*配件信息*/
			var fid1 = []
			var fid_num1 = []

			var fid = '';
			var fid_num = '';

            for (var k=0;k<=vaid;k++){
                fid1[k] = $("select[name='fid_add["+k+"]']").val();
			    fid_num1[k] = $("input[name='fid_num_add["+k+"]']").val();

				fid = fid + fid1[k] + ','
				fid_num = fid_num + fid_num1[k] + ','

            }
            /*基表参数*/
            var is_valve = $("select[name='is_valve_add']").val();
            var is_sieve = $("select[name='is_sieve_add']").val();
            var nameplate = $("select[name='nameplate_add']").val();
            var is_mark = $("select[name='is_mark_add']").val();
			/*技术参数*/
            var chain = $("select[name='chain_add']").val();
            var is_infrade = $("select[name='is_infrade_add']").val();
            var measure_mode = $("select[name='measure_mode_add']").val();
            var alarm = $("input[name='alarm_add']").val();
            var overdraft = $("input[name='overdraft_add']").val();
            var timezone = $("input[name='timezone_add']").val();
            //新添加的:表号长度
			var meter_len = $("select[name='meter_len_add']").val();

			/*软件信息*/
            var crypt = $("select[name='crypt_add']").val();
            //新添加的：sgc 出厂密钥
            var sgc = $("input[name='sgc_add']").val();
            var cry_utk = $("select[name='cry_utk_add']").val();

            var soft_version = $("select[name='soft_version_add']").val();
            var sql_db = $("select[name='sql_db_add']").val();
            var is_usbkey = $("select[name='is_usbkey_add']").val();
			/*其他信息*/
            var other = $("input[name='other_add']").val();

            var data = {'cid':client,'client_contacts':client_contacts,'order_placer':order_placer,'placer_phone':placer_phone,'transport':transport,
				'meter_id':meter_id,'order_qty':order_qty,'pro_id':pro_id,'fid':fid,'fid_num':fid_num,
				'is_valve':is_valve,'is_sieve':is_sieve,'nameplate':nameplate,'is_mark':is_mark,
				'meter_len':meter_len,'sgc':sgc,'cry_utk':cry_utk,
				'chain':chain,'is_infrade':is_infrade,'measure_mode':measure_mode,'alarm':alarm,'overdraft':overdraft,'timezone':timezone,
				'crypt':crypt,'soft_version':soft_version,'sql_db':sql_db,'is_usbkey':is_usbkey,'other':other};
            //console.log(data)
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "{:url('Order/save')}",//url
                data: data,
                success: function (result) {
                    var code = result.code
                    var msg = result.msg
                    changeText(msg, code)
                    //console.log('123'+msg)

                },
                error:function (result) {
                    var code = 0
                    var msg = '服务器错误';
                    changeText(msg, code)

                }
            });
        }
        function changeText(msg, code) {
            $('#sp').text(msg)
            if(code != 1){
                $('#img').attr('src', '__IMG__/fail.png')
            }
            $("#msg").removeClass('forhid')
            setTimeout("showOrHid()", 2000)
        }
        function showOrHid() {
            //console.log('123')
            $("#msg").addClass('forhid')
        }

        function del(oid) {
            $.post("{:url('Order/one')}",{oid:oid},function(data){
                //console.log(data);
                if(data) {
                    $("input[name='oid']").val(data[0].oid)
                }
            },'json');

        }

        $(function () {
            $(".alert-close").click(function () {
                $(".delete").css("display","none")
            })
            $(".alert-cancel").click(function () {
                $(".delete").css("display","none")
            })
            $(".class-del").click(function () {
                $(".delete").css("display","block")
            })

        })
	</script>
</body>
</html>